﻿Public Class SistemaUtil

    Public Shared Function getRutaAplicacion() As String
        Return Application.StartupPath
    End Function

    Public Shared Function isWindows64Bits() As Boolean
        Dim is64Bit As Boolean
        'is64Bit = Not String.IsNullOrEmpty(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"))

        If IntPtr.Size = 8 Then
            is64Bit = True '32 bits
        ElseIf IntPtr.Size = 4 Then
            is64Bit = False '64 bits
        End If
        Return is64Bit
    End Function


    'http://jcvonrosen.wordpress.com/2013/02/19/vb-net-shell-and-errorlevel/
    Public Shared Sub llamarComando(ByVal comando As String, ByVal argumentos As String)
        Dim psi As New ProcessStartInfo(comando, argumentos)
        'psi.WindowStyle = ProcessWindowStyle.Hidden
        psi.UseShellExecute = False ' para evitar el mensaje Warning al abrir aplicacion

        Dim p As New Process
        p.StartInfo = psi
        p.Start()
        p.WaitForExit() ' para esperar a que el proceso termine para continuar
        If p.ExitCode <> 0 Then
            Throw New ApplicationException("Llamada a '" & comando & "' ha fallado. Código de error: " & p.ExitCode.ToString())
        End If
    End Sub


End Class
